﻿@{
    ViewData["Title"] = "添加数据解析配置";
    Layout = "_Edit";
}
<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="form-add">
        <input type="hidden" class="input-text" value="@Model.ID" id="id" name="id">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>对象名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.ObjectName" placeholder="" id="objectName" name="objectName">
            </div>
        </div>
        
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>对象长度：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.ObjectLength" placeholder="" id="objectLength" name="objectLength">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>字节索引：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.BytesIndex" placeholder="" id="BytesIndex" name="BytesIndex">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>字节长度：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.BytesLength" placeholder="" id="BytesLength" name="BytesLength">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>PLC读取DB编号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                    <select class="select" size="1" name="PlcReadDbId" id="PlcReadDbId">
                        <option value="">--请选择--</option>
                        @foreach (var item in Model.PlcReadDatas)
                        {
                            if (Model.PlcReadDbId + "" == item.ID)
                            {
                                <option value="@item.ID" selected>@item.PlcName</option>
                            }
                            else
                            {
                                <option value="@item.ID">@item.PlcName</option>
                            }
                        }
                    </select>
                </span>
            </div>
        </div>
        
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="button" onclick="operate()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

@section javascript{

<script>
    $('.skin-minimal input').iCheck({
         checkboxClass: 'icheckbox-blue',
         radioClass: 'iradio-blue',
         increaseArea: '20%'
     });
     function operate(){
         var objectName=$("#objectName").val();
         if(objectName==null||objectName=="")
         {
            popupAlert('请输入对象名称',2,function(data){layer.close(data);});
           return;
         }
         var objectLength=$("#objectLength").val();
         if(objectLength==null||objectLength=="")
         {
            popupAlert('请输入对象长度',2,function(data){layer.close(data);});
           return;
         }
         
         var BytesIndex=$("#BytesIndex").val();
         if(BytesIndex==null||BytesIndex=="")
         {
            popupAlert('请输入字节索引',2,function(data){layer.close(data);});
           return;
         }
         var BytesLength=$("#BytesLength").val();
         if(BytesLength==null||BytesLength=="")
         {
            popupAlert('请输入字节长度',2,function(data){layer.close(data);});
           return;
         }
         var PlcReadDbId=$("#PlcReadDbId").val();
         if(PlcReadDbId==null||PlcReadDbId=="")
         {
            popupAlert('请选择PLC读取DB',2,function(data){layer.close(data);});
           return;
         }
        SubmitFormForAjax("/bytesmapobjectinfo/operatebytesmapobjectinfo", $("#form-add").serialize(), function (data) {
            if (data.result) {
                    popupAlert('提交成功',1,function(){closePageLayer(true);});
            }else{
                popupAlert(data.message,2,function(data){layer.close(data);});
            }
        },true);
     }
</script>
}